<template>
  <div>
    <div class="form-window">
      <div class="form-window-line"></div>
      <div class="form-window-txt">标的要素</div>
    </div>
    <div class="form-form">
      <el-form label-position="left" label-width="140px" size="small">
        <el-form-item label="房屋结构">
          <div>
            <el-select
              :disabled="edit"
              v-model="riskinfo.structure_code"
              placeholder="请选择"
              class="form-input"
            >
              <el-option
                v-for="item in selectList"
                @click.native="seleceChange(item)"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>
        </el-form-item>
        <el-form-item label="标的地址">
          <div style="display: flex">
            <el-cascader
              :disabled="edit"
              :options="optionsHyAddress"
              class="form-input"
              :props="propsHyAddress"
              :placeholder="strAddress ? strAddress : '请选择'"
              @change="changeAddress"
            ></el-cascader>
            <div style="margin-left: 20px">
              <el-input
                v-model="riskinfo.address"
                :disabled="edit"
                placeholder="请输入详细地址"
                class="form-input"
              ></el-input>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <div class="form-btn-box">
        <el-button size="small" @click="updateInfoItem(13)">修改</el-button>
        <el-button size="small" class="com-btn" @click="saveStorage(13)">保存 </el-button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    edit: { type: Boolean, default: false },
    optionsHyAddress: {},
    propsHyAddress: {},
    riskinfo: {},
  },
  data() {
    return {
      selectList: [
        {
          label: "钢筋混凝土结构",
          value: "01",
        },
        {
          label: "混合结构",
          value: "02",
        },
        {
          label: "砖木结构",
          value: "03",
        },
        {
          label: "钢结构",
          value: "04",
        },
        {
          label: "钢和钢筋混凝土结构",
          value: "05",
        },
        {
          label: "其它结构",
          value: "99",
        },
      ],
    };
  },
  computed: {
    //起运地省市区
    // departure: function () {
    //   if (this.transport.departure_province) {
    //     return (
    //       this.transport.departure_province +
    //       "/" +
    //       this.transport.departure_city +
    //       "/" +
    //       this.transport.departure_area
    //     );
    //   }
    //   return "";
    // },
    //拼接后的地址
    strAddress: function () {
      if (this.riskinfo.province) {
        return (
          this.riskinfo.province +
          "/" +
          this.riskinfo.city +
          "/" +
          this.riskinfo.area +
          "/" +
          this.riskinfo.address
        );
      }
      return "";
    },
  },
  watch: {},
  methods: {
    seleceChange(item) {
      this.riskinfo.structure_name = item.label;
    },
    changeAddress(e) {
      this.riskinfo.province = e[0];
      this.riskinfo.city = e[1];
      this.riskinfo.area = e[2];
    },

    //保存
    saveStorage(index) {
      this.$emit("saveStorage", index);
    },
    //修改
    updateInfoItem(index) {
      this.$emit("updateInfoItem", index);
    },
  },
};
</script>
<style scoped>
@import "../../../assets/css/index/form.css";
</style>
